<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('饰品名称列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>名称：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <label>散列哈希名称：</label>
                            <input type="text" name="marketHashName"/>
                        </li>
                        <!--                        <li>-->
                        <!--                            <label>cs_qaq_id：</label>-->
                        <!--                            <input type="text" name="csQaqId"/>-->
                        <!--                        </li>-->
                        <!--                        <li>-->
                        <!--                            <label>yyyp_item_id：</label>-->
                        <!--                            <input type="text" name="yyypItemId"/>-->
                        <!--                        </li>-->
                        <!--                        <li>-->
                        <!--                            <label>buff_item_id：</label>-->
                        <!--                            <input type="text" name="buffItemId"/>-->
                        <!--                        </li>-->
                        <!--                        <li>-->
                        <!--                            <label>c5_item_id：</label>-->
                        <!--                            <input type="text" name="c5ItemId"/>-->
                        <!--                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:name:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:name:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:name:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:name:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    // var editFlag = [[${@permission.hasPermi('system:name:edit')}]];
    // var removeFlag = [[${@permission.hasPermi('system:name:remove')}]];
    var prefix = ctx + "system/name";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "饰品名称",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'marketHashName',
                    title: '散列哈希名称'
                },
                // {
                //     field: 'platformList',
                //     title: '平台列表JSON'
                // },
                {
                    field: 'csQaqId',
                    title: 'cs_qaq_id',
                    visible: false
                },
                {
                    field: 'yyypItemId',
                    title: 'yyyp_item_id',
                    visible: false
                },
                {
                    field: 'buffItemId',
                    title: 'buff_item_id',
                    visible: false
                },
                {
                    field: 'c5ItemId',
                    title: 'c5_item_id',
                    visible: false
                },
                {
                    field: 'steamPrice',
                    title: 'Steam单价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return (row.steamPrice / 100).toFixed(2);
                    }
                },
                {
                    field: 'steamBalancePrice',
                    title: 'steam余额购买价格',
                    sortable: true,
                    formatter: function (value, row, index) {
                        var c5Price = row.c5Price / 100;
                        var steamBalancePrice = row.steamBalancePrice / 100;
                        var yyypPrice = row.yyypPrice / 100;
                        var buffPrice = row.buffPrice / 100;
                        if (steamBalancePrice !== 0 &&
                            (yyypPrice === 0 || steamBalancePrice < yyypPrice) &&
                            (c5Price === 0 || steamBalancePrice < c5Price) &&
                            (buffPrice === 0 || steamBalancePrice < buffPrice)) {
                            return '<span style="color: red; font-weight: bold;">' + steamBalancePrice.toFixed(2) + '</span>';
                        } else {
                            return steamBalancePrice.toFixed(2);
                        }
                    }
                },
                {
                    field: 'yyypPrice',
                    title: '悠悠单价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        var c5Price = row.c5Price / 100;
                        var steamBalancePrice = row.steamBalancePrice / 100;
                        var yyypPrice = row.yyypPrice / 100;
                        var buffPrice = row.buffPrice / 100;
                        if (yyypPrice !== 0 &&
                            (steamBalancePrice === 0 || yyypPrice < steamBalancePrice) &&
                            (c5Price === 0 || yyypPrice < c5Price) &&
                            (buffPrice === 0 || yyypPrice < buffPrice)) {
                            return '<span style="color: red; font-weight: bold;">' + yyypPrice.toFixed(2) + '</span>';
                        } else {
                            return yyypPrice.toFixed(2);
                        }
                    }
                },
                {
                    field: 'steamBalanceDiscountByYyyp',
                    title: 'C5当前价格比例',
                    sortable: true,
                    formatter: function (value, row, index) {
                        let percentage = row.steamBalanceDiscountByYyyp / 100;
                        let displayValue;
                        if (row.steamBalanceDiscountByYyyp !== 0) {
                            displayValue = percentage.toFixed(2) + '%';
                        } else {
                            displayValue = '0%';
                        }
                        // 如果百分比在70%以内，添加红色样式
                        if (percentage <= 70 && percentage > 0) {
                            return '<span style="color: red; font-weight: bold;">' + displayValue + '</span>';
                        }
                        return displayValue;
                    }
                },
                {
                    field: 'c5Price',
                    title: 'C5单价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        var c5Price = row.c5Price / 100;
                        var steamBalancePrice = row.steamBalancePrice / 100;
                        var yyypPrice = row.yyypPrice / 100;
                        var buffPrice = row.buffPrice / 100;
                        if (c5Price !== 0 &&
                            (steamBalancePrice === 0 || c5Price < steamBalancePrice) &&
                            (yyypPrice === 0 || c5Price < yyypPrice) &&
                            (buffPrice === 0 || c5Price < buffPrice)) {
                            return '<span style="color: red; font-weight: bold;">' + c5Price.toFixed(2) + '</span>';
                        } else {
                            return c5Price.toFixed(2);
                        }
                    }
                },
                {
                    field: 'steamBalanceDiscountByC5',
                    title: 'C5当前价格比例',
                    sortable: true,
                    formatter: function (value, row, index) {
                        let percentage = row.steamBalanceDiscountByC5 / 100;
                        let displayValue;
                        if (row.steamBalanceDiscountByC5 !== 0) {
                            displayValue = percentage.toFixed(2) + '%';
                        } else {
                            displayValue = '0%';
                        }
                        // 如果百分比在70%以内，添加红色样式
                        if (percentage <= 70 && percentage > 0) {
                            return '<span style="color: orange; font-weight: bold;">' + displayValue + '</span>';
                        }
                        return displayValue;
                    }
                },
                {
                    field: 'buffPrice',
                    title: 'BUFF单价',
                    sortable: true,
                    formatter: function (value, row, index) {
                        var c5Price = row.c5Price / 100;
                        var steamBalancePrice = row.steamBalancePrice / 100;
                        var yyypPrice = row.yyypPrice / 100;
                        var buffPrice = row.buffPrice / 100;
                        if (buffPrice !== 0 &&
                            (yyypPrice === 0 || buffPrice < yyypPrice) &&
                            (c5Price === 0 || buffPrice < c5Price) &&
                            (steamBalancePrice === 0 || buffPrice < steamBalancePrice)) {
                            return '<span style="color: red; font-weight: bold;">' + buffPrice.toFixed(2) + '</span>';
                        } else {
                            return buffPrice.toFixed(2);
                        }
                    }
                },
                {
                    field: 'steamBalanceDiscountByBuff',
                    title: 'BUFF当前价格比例',
                    sortable: true,
                    formatter: function (value, row, index) {
                        let percentage = row.steamBalanceDiscountByBuff / 100;
                        let displayValue;
                        if (row.steamBalanceDiscountByBuff !== 0) {
                            displayValue = percentage.toFixed(2) + '%';
                        } else {
                            displayValue = '0%';
                        }
                        // 如果百分比在70%以内，添加红色样式
                        if (percentage <= 70 && percentage > 0) {
                            return '<span style="green: orange; font-weight: bold;">' + displayValue + '</span>';
                        }
                        return displayValue;
                    }
                },
                {
                    field: 'status',
                    title: 'status',
                    sortable: true,
                },
                {
                    field: 'createDate',
                    title: '创建时间',
                    sortable: true,
                },
                {
                    field: 'updateDate',
                    title: '更新时间',
                    sortable: true,
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // 新增一个开关

                        // actions.push('<a class="btn btn-danger btn-xs ' + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>